{include file="common/head"}
<head>
<title>分类编辑</title>
<style type="text/css">
  .form-controlx{width: initial;display: inline-block;}
</style>
</head>
<body style="">
    <div class="container p-3 my-3 " style="max-width: 600px;"  >
    <h2>分类编辑</h2>
    <form method="post" enctype="multipart/form-data" action="/index.php/cat/edit">

      <input type="hidden" name="id" id="id" value="{$data.id}" />

       <div class="mb-3 mt-3">
        <lable for="fid" class="form-label">父类(Categray):</label>

        <select id="fid" name="fid" class="form-control">
            {foreach $category as $k=>$v}
            <option value="{$k}" {if $data.fid==$v['id']}selected{/if} >
              {if $v['deepth']==1}
                |__
              {elseif $v['deepth']==2}
                &nbsp;&nbsp;&nbsp;&nbsp;|
              {elseif $v['deepth']==3}
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|__         
              {/if}
              {$v['name']}
              </option>
            {/foreach} 
        </select>

      </div>
      <div class="mb-3 mt-3">
        <lable for="name" class="form-label">名称:</label>
        <input type="text" class="form-control" id="name" name="name" value="{$data.name}" placeholder="Goods name" />
      </div>
      <div class="mb-3">
        <label for="title" class="form-label">说明:</label>
        <input type="text" class="form-control" id="title" name="title" value="{$data.title}" placeholder="Title" />
      </div>  

      <div class="mb-3">
        <label for="sort" class="form-label">排序:</label>
        <input type="text" class="form-control" id="sort" name="sort" value="{$data.sort}" placeholder="Sort" />
      </div>


      <div class="mb-3 text-center">
        <label for="price_per_km" class="form-label">图(image):</label>        
        <img id="img" src="{$data.img}" style="width:90px;min-width: 90px;min-height: 30px;border: 1px solid #ccc;margin:0 auto;" alt="Image" />
        <input type="file"  name="file" id="file"  /> <br> 
       </div>



      <div class="mb-3">
        <label for="status" class="form-label">是否启用(Using):</label>
          <input type="radio" class="form-check-input" id="radio1" name="status" value="1" {if $data.status==1} checked {/if}/> 
          <label class="form-check-label" for="radio1">启用(Using)</label>
          <input type="radio" class="form-check-input" id="radio2" name="status" value="2" {if $data.status==2} checked {/if}/>
          <label class="form-check-label" for="radio2">停用(Stoped)</label>
       </div>
      <button  type="button" class="btn btn-primary" onclick="doSave()">保存(Save)</button>

    </form>
    </div>

<script type="text/javascript">
    function doSave(){
      if(!$("#name").val()) {
        layer.msg("无效的分类名称(Invalid category name)!");
        return 0;
      }    
      //询问框
      layer.confirm('是否确定保存分类?', {
        btn: ['YES','CANCEL'] //按钮
      }, function(){
        $('form').submit();
      }, function(){
        layer.msg("Cancel!");
        return 0;
      });
    }

</script>


</body>
</html>
